package net.cyue.nest.nestjava.common.interfaces;

import net.cyue.nest.nestjava.common.data.http.CORSOption;
import net.cyue.nest.nestjava.common.interfaces.feature.INestInterceptor;
import net.cyue.nest.nestjava.common.interfaces.http.IHTTPServer;
import net.cyue.nest.nestjava.common.interfaces.http.IRequestHandler;

public interface INestApplication<TServerAdapter extends IHTTPServer>
  extends INestApplicationContext
{
  /**
   * A wrapper function around HTTP adapter method: `adapter.use()`.
   * Example `app.use(cors())`
   **/
  public INestApplication<TServerAdapter> use(IRequestHandler... args);
  public void enableCoors(CORSOption option);

  public void listen(int port);
  public void listen(int port, Callback callback);

  /**
   * Returns the url the application is listening at, based on OS and IP version. Returns as an IP value either in IPv6 or IPv4
   */
  public String getURL();

  public INestApplication<TServerAdapter> setGlobalPrefix(String prefix);

  public IHTTPServer getHTTPServer();
  public TServerAdapter getHTTPAdapter();

  public INestApplication<TServerAdapter> useGlobalInterceptors(INestInterceptor... interceptors);

  public void close();
}

